package com.shangma.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
public class SpringTask {
    @Autowired
    private RestTemplate restTemplate;

    // 秒 分  时  日 月  周  年
//    @Scheduled(cron = "5/20 * * 5 W ?")
    public String getData(){
        String path = "http://api.tianapi.com/tianqi/index?key=7c4e55e6efd90f0baa513c07bcbffbfb&city=郑州市";
        String forObject = restTemplate.getForObject(path, String.class);
        System.out.println(forObject);
        return forObject;
    }
}
